package com.hui.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hui.entity.dao.StoreProductAttrValue;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 商品属性值表(StoreProductAttrValue)表数据库访问层
 *
 * @author hui
 * @since 2022-07-17 11:40:42
 */
public interface StoreProductAttrValueMapper extends BaseMapper<StoreProductAttrValue> {

    @Update({"update store_product_attr_value set stock=stock+#{num}, sales=sales-#{num} where product_id=#{productId} and `unique`=#{unique}"})
    int incStockDecSales(@Param("num") Integer num, @Param("productId") Long productId, @Param("unique") String unique);

    @Update({"update store_product_attr_value set stock=stock+#{num}, pink_stock=pink_stock+#{num}, sales=sales-#{num} where product_id=#{productId} and `unique`=#{unique}"})
    int incCombinationStockDecSales(@Param("num") Integer num, @Param("productId") Long productId, @Param("unique") String unique);

    @Update({"update store_product_attr_value set stock=stock+#{num},seckill_stock=seckill_stock+#{num}, sales=sales-#{num} where product_id=#{productId} and `unique`=#{unique}"})
    int incSeckillStockDecSales(@Param("num") Integer num, @Param("productId") Long productId, @Param("unique") String unique);

}

